home *** CD-ROM | disk | FTP | other *** search
Wrap
/* SendMail.thor by Troels Walsted Hansen <troels@stud.cs.uit.no> ** $VER: SendMail.thor v1.10 (27.12.95) ** ** This is a very simple script designed for use with AMosaic's new mailto: ** support. Set ENV:Editor to your prefered editor (I use "GED Y"), and ** ENV:SendMail to "RX THOR:Rexx/SendMail.thor" (substitute "THOR:Rexx/" for ** the path where you put this script). ** ** Now change the two variables below to whatever fits for your setup. ** MailSystem is the name of your TCP/SOUP/UUCP/whatever email system in ** THOR, and MailConfName is obviously the name of your email conference in ** THOR. ** ** Setting AddSignature to 'Yes' will make SendMail.thor read your conference/ ** BBS/global signature settings and add that signature to your mails. ** ** Sending a mailto: with AMosaic should now produce an EnterMsg event in THOR. ** The mail will be sent the next time you use Send Events from ConnectTHOR, ** upload your SOUP reply package, or whatever. ** ** Note: THOR does not have to be running for this script to work! ** ** History: ** ¯¯¯¯¯¯¯¯ ** SendMail.thor v1.00 (07.08.95) ** · First release. ** ** SendMail.thor v1.10 (27.12.95) ** · Now optionally appends signature configured in THOR to the email. ** · Updated my email address :-) ** · Implemented previously non-existant errorchecking and reporting */ MailSystem = 'News&Mail' MailConfName = 'EMail' AddSignature = 'Yes' /* DON'T CHANGE ANYTHING BELOW HERE */ if ~show('p', 'BBSREAD') then do address command "run >nil: `GetEnv THOR/THORPath`bin/LoadBBSRead" "WaitForPort BBSREAD" end address(BBSREAD) /* parse the header AMosaic provides */ str = readln('STDIN') if(upper(word(str, 1)) ~= "TO:") then do call showerror("First headerline wasn't a To:, please don't mess with the header AMosaic provides.") exit 20 end else EVENT.TOADDR = word(str, 2) str = readln('STDIN') if(upper(word(str, 1)) ~= "SUBJECT:") then do call showerror("Second headerline wasn't a Subject:, please don't mess with the header AMosaic provides.") exit 20 end else EVENT.SUBJECT = substr(str, 10) /* skip X-Mailer: line */ call readln('STDIN') /* put the body of the message in a file with a unique name */ UNIQUEMSGFILE bbsname '"'MailSystem'"' stem UNIQUEFILE if(rc ~= 0) then do call showerror('UNIQUEMSGFILE BBSRead command failed: ' || BBSREAD.LASTERROR) exit 20 end call open(tmp, UNIQUEFILE.NAME, W) do until eof('STDIN') call writeln(tmp, readln('STDIN')) end /* add signature from the EMail conference/BBS/Global Settings */ if(upper(AddSignature) = 'YES') then do GETCONFDATA BBSNAME '"'MailSystem'"' CONFNAME '"'MailConfName'"' STEM CONFD if(CONFD.SIGNATURE = "") then do GETBBSDATA BBSNAME '"'MailSystem'"' STEM BBSD if(BBSD.SIGNATURE = "") then do GETGLOBALDATA STEM GLOBD if(GLOBD.SIGNATURE = "") then do call showerror('No signature configured in either conference, bbs og global settings! Please correct this in THOR or turn off signature adding in SendMail.thor.') exit 20 end else sig = GLOBD.SIGNATURE end else sig = BBSD.SIGNATURE end else sig = CONFD.SIGNATURE drop CONFD.; drop BBSD.; drop GLOBD. if(sig ~= "") then do /* signature may be a filename */ if(exists(sig)) then do call open(sigfh, sig, R) do until eof(sigfh) call writeln(tmp, readln(sigfh)) end call close(sigfh) end else call writeln(tmp, sig) /* or just a string */ end end call close(tmp) /* fill out some more variables that BBSREAD require */ EVENT.CONFERENCE = MailConfName EVENT.MSGFILE = UNIQUEFILE.FILEPART /* write the event */ WRITEBREVENT bbsname '"'MailSystem'"' event 0 stem EVENT if(rc ~= 0) then do call showerror('WRITEBREVENT BBSRead command failed: ' || BBSREAD.LASTERROR) exit 20 end exit 0 /* sophisticated errorhandling :-) */ showerror: procedure expose MailSystem MailConfName AddSignature parse arg errormsg p=show('P',,) if(pos('AMOSAIC.', p) > 0) then amosaicport = word(substr(p, pos('AMOSAIC.', p)), 1) else return call open(err, "T:SendMail.thor.error.html", W) call writeln(err, "<HTML><HEAD><TITLE>SendMail.thor encountered an error</TITLE></HEAD><BODY><H1>Sending mail aborted</H1>" || errormsg || "<P>Please remember to verify the following settings:<PRE>MailSystem = '" || MailSystem || "'" || '0a'x || "MailConfName = '" || MailConfName || "'" || '0a'x || "AddSignature = '" || AddSignature || "'" || "</PRE>If they are wrong, edit SendMail.thor and correct them. <hr> If this should happen to be an erroneous error, don't hesitate to contact the author, <A HREF=" || '"' || "http://www.cs.uit.no/~troels" || '"' || ">Troels Walsted Hansen</A>, preferably by <A HREF=" || '"' || "mailto:troels@stud.cs.uit.no" || '"' || ">email</A>.") call close(err) address(amosaicport) 'JUMP URL file://localhost/T:SendMail.thor.error.html' return